<!--  -->
<template>
  <div class="grammer-study">
    <div class="chose-course-top">
      <div class="header-left">
        <span
          class="back-arrow"
          @click="() => this.$router.push('/study/grammar?ref=homepage ')"
        ></span>
      </div>
      <div class="course-title">
        {{ this.$route.query.type === "0" ? "今日学习" : "累计学习" }}
      </div>
      <div class="btn-group"></div>
    </div>
    <div class="list-wrap" v-if="learnList.length">
      <studyList :renderData="learnList"></studyList>
    </div>
  </div>
</template>

<script>
import studyList from "./studyList";
export default {
  name: "grammarStudy",
  components: {
    studyList,

  },
  data() {
    return {
      learnList: [],
    };
  },
  computed: {},
  watch: {},
  methods: {
    fetchLearningList() {
      fetchLearningToday(this.$route.query).then((res) => {
        if (res.code === SUCCESS_CODE) {
          this.learnList = res.data.list.map((v) =>
            Object.assign(v, { clickNum: 0 })
          );
        }
      });
    },
  },
  created() {
    this.learnList =
     [
       {
         "id": 1636,
         "title": "He was punished because he did not obey the rule.",
         "translation": "他因为不遵守规章制度而受到惩罚。",
         "detail": null,
         "voice": "https:\/\/777-video.oss-cn-beijing.aliyuncs.com\/grammar\/US\/voice\/d1e8d63078f6bd656ff7b2d987b2738aac4da9840ebf687b4940aab1072c3a1b.wav",
         "keys_words": "because"
       }, {
       "id": 1637,
       "title": "He arrived after the game started.",
       "translation": "比赛开始后他才到。",
       "detail": null,
       "voice": "https:\/\/777-video.oss-cn-beijing.aliyuncs.com\/grammar\/US\/voice\/5999f14cd045b4b132ff174939d34eee3af842b4d3c412505c505200580ea82d.wav",
       "keys_words": "after"
     }, {
       "id": 1638,
       "title": "She did not understand me before I explained to her.",
       "translation": "在我向她解释之前，她没有听懂我的话。",
       "detail": null,
       "voice": "https:\/\/777-video.oss-cn-beijing.aliyuncs.com\/grammar\/US\/voice\/324c5c83d62a541dd4471e0f9918e3fda28d0f34c8fa9c41d3303e0c0c846cdc.wav",
       "keys_words": "before"
     }, {
       "id": 1639,
       "title": "Although he has a lot of money, he is still unhappy.",
       "translation": "虽然他有很多钱，但他仍然不快乐。",
       "detail": null,
       "voice": "https:\/\/777-video.oss-cn-beijing.aliyuncs.com\/grammar\/US\/voice\/746b4dc1236d09b43f729f6bce8bc40f080dd6c5604fd4feecad9dcbb0735422.wav",
       "keys_words": "Although"
     }, {
       "id": 1641,
       "title": "Wherever you go, I'll be right here waiting for you.",
       "translation": "无论你到哪里，我都会在这里等你。",
       "detail": null,
       "voice": "https:\/\/777-video.oss-cn-beijing.aliyuncs.com\/grammar\/US\/voice\/615f2eaee6ee44870274a106835d7f20c455ac7fbfd5153423bb018a99492853.wav",
       "keys_words": "Wherever"
     }
     ]
    this.learnList = this.learnList.map((v) => ({
      ...v,
      clickNum: 0
    }));
    // this.fetchLearningList();
  },
  mounted() {},
  beforeCreate() {},
  beforeMount() {},
  beforeUpdate() {},
  updated() {},
  beforeDestroy() {},
  destroyed() {},
  // beforeRouteLeave(to, from, next) {
  //   fetchEndTime(this.$route.query);
  //   next();
  // },
};
</script>
<style scoped>
.grammer-study {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;

  .list-wrap {
    flex: 1;
    overflow-y: auto;
    background: #F0F2F4;
    padding: 30px 40px;
  }
  .chose-course-top {
    text-align: center;
    display: flex;
    justify-content: space-between;
    position: relative;
    align-items: center;
    height: 80px;
    padding: 0 40px;
    background-color: #fff;
    .anticon {
      font-size: 24px; /* no */
    }

    .header-left {
      flex: 1;
      display: flex;
      align-items: center;
      justify-content: flex-start;
      .back-arrow {
        width: 30px;
        height: 27px;
        background-image: url("@/assets/home/btn_back.png");
        background-size: 100%;
        cursor: pointer;
      }
    }

    .course-title {
      width: 100%;
      flex: 1;
      font-size: 20px;
      font-weight: 700;

      .check-title {
        color: #c7c7c7;
      }
    }
    .btn-group {
      flex: 1;
    }
  }
}
</style>
